﻿<UserControl 
    x:Class="EditContactItemsControlSelectionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:WPFLOBMVVM"
    xmlns:Ocean_WPF="clr-namespace:Ocean.OceanFramework.WPF;assembly=OceanFrameworkWPF"
    xmlns:Ocean_MVVM="clr-namespace:Ocean.OceanFramework.MVVM;assembly=OceanFrameworkWPF">

    <DockPanel LastChildFill="True">

        <Grid DockPanel.Dock="Top" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <ToolBarTray VerticalAlignment="Top" >
                <ToolBar>
                    <Ocean_WPF:CustomToolBarButton Command="{Binding Path=NewCommand}" ShowButtonText="True" ShowButtonImage="True" ButtonLayout="Horizontal" ButtonText="New" EnabledButtonImage="../Resources/Images/New.png" ToolTip="Create new contact" DisabledButtonImage="../Resources/Images/NewDisabled.png" MouseOverForeground="Black" />
                    <Ocean_WPF:CustomToolBarButton Command="{Binding Path=SaveCommand}" ShowButtonText="True" ShowButtonImage="True" ButtonLayout="Horizontal" ButtonText="Save" EnabledButtonImage="../Resources/Images/Save.png" ToolTip="Save contact" DisabledButtonImage="../Resources/Images/SaveDisabled.png"  MouseOverForeground="Black" />
                    <Separator Focusable="False" />
                    <Ocean_WPF:CustomToolBarButton Command="{Binding Path=DeleteCommand}" ShowButtonText="True" ShowButtonImage="True" ButtonLayout="Horizontal" ButtonText="Delete" EnabledButtonImage="../Resources/Images/Delete.png" ToolTip="Delete contact" DisabledButtonImage="../Resources/Images/DeleteDisabled.png" MouseOverForeground="Black" />
                </ToolBar>
            </ToolBarTray>

            <Ocean_WPF:CustomToolBarButton Command="{Binding Path=RequestCloseCommand}" ButtonText="Close" EnabledButtonImage="../Resources/Images/Close.png" ToolTip="Close contact form" DisabledButtonImage="../Resources/Images/CloseDisabled.png" Grid.Column="2" VerticalAlignment="Top"/>
        </Grid>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="3" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Border Margin="11" BorderBrush="LightGray" BorderThickness="1" CornerRadius="10" Padding="10" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Text="WPF Disciples" Margin="0,7" FontFamily="Aerial" FontWeight="Bold" Background="WhiteSmoke" />
                    
                    <ScrollViewer Grid.Row="1">
                        
                        <ItemsControl IsTabStop="False" ItemsSource="{Binding Path=AllContacts}" >
                            
                            <ItemsControl.Resources>
                                <Style TargetType="{x:Type TextBlock}" x:Key="discipleNameStyle">
                                    <Setter Property="Margin" Value="2" />
                                    <Style.Triggers>
                                        <Trigger Property="TextBlock.IsMouseOver" Value="true">
                                            <Setter Property="Background" Value="#10000000" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </ItemsControl.Resources>
                                
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock x:Name="tbParent" Style="{StaticResource discipleNameStyle}">
                                        <Hyperlink Focusable="False" Foreground="Black" TextDecorations="None" Command="{Binding Path=DataContext.SelectCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" CommandParameter="{Binding Path=Id}" >
                                            <TextBlock Width="{Binding ElementName=tbParent, Path=ActualWidth, Mode=OneWay}" Text="{Binding Path=FullName}" />                                            
                                        </Hyperlink>
                                    </TextBlock>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                        
                    </ScrollViewer>
                </Grid>
            </Border>

            <GridSplitter HorizontalAlignment="Left" Background="DarkGray" ResizeDirection="Columns" Grid.Column="1" Width="3" />
            
            <local:ContactView x:Name="objContactView" Grid.Column="2" DataContext="{Binding ContactViewModel}" />

        </Grid>

    </DockPanel>

</UserControl>
